<?php

namespace App\Console\Commands;

use App\Services\XFYUNService;
use Exception;
use Illuminate\Console\Command;
use WebSocket\Client;

class XFYUN_CHAT extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:xfyun_chat';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $message = ["text" => [
            // array("role" => "user", "content" => "你是谁"),
            // array("role" => "assistant", "content" => "....."),
            ["role" => "user", "content" => "都江堰有什么独特之处"]
        ]];

        try {
           $text = XFYUNService::chat($message);
           $this->info($text);
        } catch (Exception $e) {
            $this->error("链接异常:" . $e->getMessage());
            return;
        }
    }
}
